package com.lagou.controller;

import com.lagou.domain.Employee;
import com.lagou.service.EmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@RequestMapping("/employee")
public class EmployeeController {

    @Autowired
    private EmployeeService employeeService;

    @RequestMapping("/findAll")
    public String findAll(Model model) {
        model.addAttribute ("employeeList",employeeService.findAll ());
        return "list";
    }

    @RequestMapping("/save")
    public String save(Employee employee) {
        employeeService.saveEmployee (employee);
        return "redirect:/employee/findAll";
    }
}
